home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / netconf / netconf.h < prev    next >
C/C++ Source or Header  |  1996-08-03  |  6KB  |  277 lines

  1. #pragma interface
  2. #ifndef NETCONF_H
  3. #define NETCONF_H
  4.  
  5. #include "../paths.h"
  6.  
  7. #include <stdio.h>
  8.  
  9. #include "../misc/misc.h"
  10.  
  11.  
  12. class NETCONF_HELP_FILE: public HELP_FILE{
  13.     /*~PROTOBEG~ NETCONF_HELP_FILE */
  14. public:
  15.     NETCONF_HELP_FILE (const char *fname);
  16.     /*~PROTOEND~ NETCONF_HELP_FILE */
  17. };
  18.  
  19. /*
  20.     A HOST simply contain a single line of /etc/hosts.
  21.     It will remember comments. Line containing only a comment will
  22.     be store with name1 and others == NULL.
  23. */
  24. class HOST: public ARRAY_OBJ{
  25. protected:
  26.     SSTRING name1;
  27.     SSTRING others;        // Other name (alias)
  28.     SSTRING ip_num;        // Even the IP number is stored as a string
  29.                         // It allows "editing" completly broken
  30.                         // /etc/hosts file.
  31.     SSTRING comment;
  32.     char is_valid;        // Tells if the record is valid
  33.                         // If not, it is managed as a comment
  34.     /*~PROTOBEG~ HOST */
  35. public:
  36.     HOST (const char *_ip_num,
  37.          const char *_name1,
  38.          const char *_others,
  39.          const char *_comment);
  40.     HOST (const char *buf);
  41.     HOST (void);
  42.     virtual int edit (HELP_FILE&helpfile);
  43. private:
  44.     void freeall (void);
  45. public:
  46.     const char *getcomment (void)const;
  47.     const char *getipnum (void)const;
  48.     const char *getname1 (void)const;
  49.     const char *getothers (void)const;
  50.     virtual int is_special (void)const;
  51.     int iscomment (void)const;
  52.     virtual void print (FILE *fout)const;
  53.     void set (const char *buf);
  54.     void setcomment (const char *_comment);
  55.     void setipnum (const char *_ipnum);
  56.     void setname1 (const char *_name1);
  57.     void setothers (const char *_others);
  58.     virtual ~HOST (void);
  59.     /*~PROTOEND~ HOST */
  60. };
  61. class NETWORK: public HOST{
  62.     /*~PROTOBEG~ NETWORK */
  63. public:
  64.     NETWORK (const char *_ip_num,
  65.          const char *_name1,
  66.          const char *_others,
  67.          const char *_comment);
  68.     NETWORK (const char *buf);
  69.     NETWORK (void);
  70.     int is_special (void)const;
  71.     void print (FILE *fout)const;
  72.     /*~PROTOEND~ NETWORK */
  73. };
  74.  
  75. class HOSTS: public ARRAY{
  76. protected:
  77.     CONFIG_FILE *cfgf;
  78.     /*~PROTOBEG~ HOSTS */
  79. public:
  80.     HOSTS (void);
  81.     void add (HOST *pt);
  82.     virtual void add (const char *_ip_num,
  83.          const char *_name1,
  84.          const char *_others,
  85.          const char *_comment);
  86.     virtual void add (const char *buf);
  87.     int edit (const char *title, HELP_FILE&helpfile);
  88.     HOST *getitem (const char *name)const;
  89.     HOST *getitem (int no)const;
  90.     virtual HOST *newhost (const char *_ip_num,
  91.          const char *_name1,
  92.          const char *_others,
  93.          const char *_comment);
  94.     virtual HOST *newhost (const char *buf);
  95.     int read (void);
  96.     int write (void)const;
  97.     /*~PROTOEND~ HOSTS */
  98. };
  99. class NETWORKS: public HOSTS{
  100.     /*~PROTOBEG~ NETWORKS */
  101. public:
  102.     NETWORKS (void);
  103.     virtual HOST *newhost (const char *_ip_num,
  104.          const char *_name1,
  105.          const char *_others,
  106.          const char *_comment);
  107.     virtual HOST *newhost (const char *buf);
  108.     /*~PROTOEND~ NETWORKS */
  109. };
  110.  
  111. class THISHOST{
  112.     char *name1;        // Principal name of this host
  113.     char ip_num[16];
  114.     char is_config;        // Is it currently configured
  115.     /*~PROTOBEG~ THISHOST */
  116. public:
  117.     THISHOST (void);
  118.     int configok (void);
  119.     const char *getipnum (int);
  120.     const char *getname1 (void);
  121.     void setname1 (const char *newname1);
  122.     ~THISHOST (void);
  123.     /*~PROTOEND~ THISHOST */
  124. };
  125.  
  126. // Information on a process ID
  127. class PROC{
  128.     PROC *next;
  129.     int pid;
  130.     char *path;        // Path of the program
  131.     char *name;        // Pointer into path
  132.     /*~PROTOBEG~ PROC */
  133. public:
  134.     PROC (int _pid, PROC *_next);
  135.     const char *getname (void);
  136.     PROC *getnext (void);
  137.     const char *getpath (void);
  138.     long getstarttime (void);
  139.     int isok (void);
  140.     int kill (int signo);
  141.     ~PROC (void);
  142.     /*~PROTOEND~ PROC */
  143. };
  144.  
  145. /*
  146.     Control the startup of daemons
  147. */
  148. class DAEMON{
  149. protected:
  150.     DAEMON *next;
  151.     char *name;
  152.     char *path;
  153.     char *args;
  154.     char managed;
  155.     char override;    // Path or argument has been changed by the admin
  156.                     // and must be saved in /etc/conf.linuxconf
  157.     /*~PROTOBEG~ DAEMON */
  158. public:
  159.     DAEMON (void);
  160.     int edit (void);
  161.     int exist (void);
  162.     const char *getargs (void);
  163.     const char *getname (void);
  164.     DAEMON *getnext (void);
  165.     const char *getpath (void);
  166.     void init (int _managed,
  167.          const char *_name,
  168.          const char *buf,
  169.          DAEMON *_next);
  170.     int is_managed (void);
  171.     int is_overriden (void);
  172.     int isok (void);
  173.     int kill (int signal_num);
  174.     virtual int restart (void);
  175.     void set_managed (int _managed);
  176.     void set_override (int _over);
  177.     void setspec (const char *_path, const char *_args);
  178.     int signal (int signal_num,
  179.          const char *msg,
  180.          const char *sem_file);
  181.     int signal (int signal_num, const char *msg);
  182.     virtual int start (void);
  183.     virtual int startif (void);
  184.     int startif_date (long date);
  185.     int startif_file (const CONFIG_FILE&cfile);
  186.     int startif_file (const char *fname);
  187.     virtual int stop (void);
  188.     int system (const char *cmd);
  189.     void write (FILE *fout);
  190.     virtual ~DAEMON (void);
  191.     /*~PROTOEND~ DAEMON */
  192. };
  193.  
  194. class ROUTE: public ARRAY_OBJ{
  195.     SSTRING ip_dst;
  196.     SSTRING ip_gateway;
  197.     SSTRING netmask;
  198.     SSTRING flags;
  199.     int tag;        // Application placeholder
  200.     SSTRING invalid_line;    // Contain an unparsable line from ETC_CONF_ROUTE
  201.     SSTRING iface;
  202.     /*~PROTOBEG~ ROUTE */
  203. public:
  204.     ROUTE (const char *buf, int noline);
  205.     ROUTE (const char *dst,
  206.          const char *gate,
  207.          const char *mask,
  208.          const char *_flags,
  209.          const char *_iface);
  210.     ROUTE (void);
  211.     int compare (const SSTRING&dst,
  212.          const SSTRING&gateway,
  213.          const SSTRING&o_netmask,
  214.          const SSTRING&o_flags);
  215.     int dst_is_host (void);
  216.     int edit (int edit_host_route);
  217.     const char *getdst (void);
  218.     const char *getgateway (void);
  219.     const char *getiface (void);
  220.     int gettag (void);
  221.     int is_default (void);
  222.     int is_loopback (void);
  223.     int isdevice (void);
  224.     int kill (void);
  225.     int match (const SSTRING&dst);
  226.     void settag (int _tag);
  227.     void write (FILE *fout);
  228.     ~ROUTE (void);
  229.     /*~PROTOEND~ ROUTE */
  230. };
  231.  
  232. class ROUTES: public ARRAY{
  233.     /*~PROTOBEG~ ROUTES */
  234. public:
  235.     ROUTE *find (const SSTRING&ip_dst);
  236.     ROUTE *getitem (int no)const;
  237.     int readactive (void);
  238.     void readbyme (void);
  239.     void write (FILE *fout);
  240.     void writebyme (void);
  241.     /*~PROTOEND~ ROUTES */
  242. };
  243.  
  244. class NIS_CONF{
  245.     SSTRING domain;
  246.     SSTRING server;
  247.     /*~PROTOBEG~ NIS_CONF */
  248. public:
  249.     NIS_CONF (void);
  250.     int configok (void);
  251.     int edit (void);
  252.     const char *getdomain (void);
  253.     const char *getserver (void);
  254.     int valid_server (void);
  255.     void write (void);
  256.     /*~PROTOEND~ NIS_CONF */
  257. };
  258.  
  259. struct IFCONFIG_INFO {
  260.     int flags;
  261.     char ip_addr[16];
  262.     char dst_addr[16];
  263.     char netmask[16];
  264. };
  265.  
  266.  
  267. #include "../dialog/dialog.h"
  268. #include <stdio.h>
  269.  
  270. struct hostent;
  271. struct HOSTINFO;
  272.  
  273. #include "netconf.p"
  274.  
  275. #endif
  276.  
  277.